package com.community.service.impl;

import com.community.common.annotation.DataScope;
import com.community.common.core.domain.entity.SysUser;
import com.community.common.utils.DateUtils;
import com.community.common.utils.SecurityUtils;
import com.community.domain.StudentEntity;
import com.community.mapper.StudentMapper;
import com.community.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @DataScope(deptAlias = "d",userAlias = "u")
    @Override
    public List<StudentEntity> selectStudentList(StudentEntity student) {
        return studentMapper.selectStudentList(student);
    }
    @Override
    public Integer addStudent(StudentEntity student) {
        student.setCreateTime(DateUtils.getNowDate());
        student.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
        return studentMapper.addStudent(student);
    }
    @Override
    public int updStudent(StudentEntity student)
    {
        return studentMapper.updStudent(student);
    }

    @Override
    public int delStudent(int id) {
        return studentMapper.delStudent(id);
    }

    @Override
    public StudentEntity selectStudentInfoById(int id) {
        return studentMapper.selectStudentInfoById(id);
    }
}
